﻿using System;

/* 求1(含)~99(含)所有奇数的和，用递归实现 */
namespace Practice3
{
    public class Practice
    {
        static int GetOddSum(int num, int current = 1)
        {
            if(current > num)
            {
                return 0;
            }

            return current + GetOddSum(num, current + 2);
        }

        public static void Execute()
        {
            Console.Write("请输入终止数: ");
            int num = int.Parse(Console.ReadLine());
            int res = GetOddSum(num);
            Console.WriteLine("res: {0}", res);
        }
    }
}